package com.rbs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.rbs.entity.Department;
import com.rbs.mapper.DepartmentMapper;
import com.rbs.service.IDepartmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 部门表 服务实现类
 * </p>
 *
 * @author lisl
 * @since 2024-04-07
 */
@Service
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public boolean findSameDepartName(Department department) {
        LambdaQueryWrapper<Department> wrapper=new LambdaQueryWrapper<Department>().eq(Department::getDStrname,department.getDStrname());
        boolean flag=departmentMapper.exists(wrapper);
        return flag;
    }

    @Override
    public List<Department> findByName(Department department) {
        LambdaQueryWrapper<Department> wrapper=new LambdaQueryWrapper<Department>().like(department.getDStrname()!=null,Department::getDStrname,department.getDStrname());
        List<Department> list = departmentMapper.selectList(wrapper);
        return list;
    }

}
